package com.xaioran.springMQ.SpringToPIC;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.jms.TextMessage;

@Service
public class SpringMQ_produceT {
    @Autowired
    private JmsTemplate jmsTemplate;
    public static void main(String args[]){
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicatTOPIC.xml");
        SpringMQ_produceT produce=  applicationContext.getBean(SpringMQ_produceT.class);
        /*produce.jmsTemplate.send(new MessageCreator() {
            @Override
            public Message createMessage(Session session) throws JMSException {
                TextMessage textMessage=session.createTextMessage("********Spring和ACtiveMQ的整合");
                return null;
            }
        });
        */
        produce.jmsTemplate.send(session -> {
            TextMessage textMessage=session.createTextMessage("********Spring和ACtiveMQ的整合1111111");
            return textMessage;
        });
        System.out.println("************send tadk over");
    }
}
